import React, { useRef } from 'react'
function Child () {
  // const [ count, setCount ] = useState(100)
  // const fn = () => {
  //   console.log('count', count)
  // }

  return (
    <div>
      child
    </div>
  )
}
function App() {
  // useRef 在函数式组件中 无法直接获取到子组件的实例
  const inputRef = useRef(null)
  const childRef = React.createRef()
  const getData = () => {
    console.log(inputRef.current.value)
    console.log(childRef) // {current: null}
  }
  return (
    <div>
      <input type="text" ref = { inputRef }/>
      <Child ref = { childRef }/>
      <button onClick={getData}>获取数据</button>
    </div>
  )
}

export default App
